package com.wclass.controller.app;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.wclass.common.ReturnObject;
import com.wclass.entity.BaseTeamPic;
import com.wclass.entity.BaseTeamUser;
import com.wclass.interceptor.IgnoreAuth;
import com.wclass.service.IBaseTeamPicService;
import com.wclass.service.IBaseTeamUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 团队介绍-图片 前端控制器
 * </p>
 *
 * @author SEN
 * @since 2019-02-14
 */
@Api(description = "团队介绍")
@RestController
@RequestMapping("/team")
public class TeamController {
    @Autowired
    private IBaseTeamUserService teamUserService;
    @Autowired
    private IBaseTeamPicService teamPicService;

    @IgnoreAuth
    @ApiOperation("获取团队主要成员List")
    @RequestMapping(value = "/getTeamUserList", method = RequestMethod.POST)
    public ReturnObject<List<BaseTeamUser>> getTeamUserList() {
        EntityWrapper ew = new EntityWrapper<BaseTeamUser>();
        ew.orderBy("sort");
        return new ReturnObject<>(0, "获取成功", teamUserService.selectList(ew));
    }

    @IgnoreAuth
    @ApiOperation("获取团队风采分页")
    @RequestMapping(value = "/getTeamPicPage", method = RequestMethod.POST)
    public ReturnObject<List<BaseTeamPic>> getTeamPicPage(@ApiParam("每页条数") @RequestParam(defaultValue = "10") Integer limit,
                                                          @ApiParam("页数") @RequestParam(defaultValue = "1") Integer offset) {
        EntityWrapper ew = new EntityWrapper<BaseTeamPic>();
        ew.orderBy("sort");
        Page<BaseTeamPic> obj = teamPicService.selectPage(new Page<>(offset, limit), ew);
        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

}

